﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DatavalidationSample
{
    public class MainWindowViewModel : ValidationViewModelBase
    {
        private string _firstName = string.Empty;
        [Required(AllowEmptyStrings = false, ErrorMessage = "First name should not be empty")]
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; OnPropertyChanged("FirstName"); }
        }

        private string _lastName = string.Empty;
        [Required(AllowEmptyStrings = false, ErrorMessage = "LastName should not be Empty")]
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; OnPropertyChanged("LastName"); }
        }

        private int _age;
        [Required(ErrorMessage = "Age Fields required")]
        [Range(1, 130, ErrorMessage = "Value between 1 to 100")]
        public int Age
        {
            get { return _age; }
            set { _age = value; OnPropertyChanged("Age"); }
        }

        private string _mobileNo;
        [Required(ErrorMessage = "Field 'Mobile No' is required.")]
        [RegularExpression("[0-9]{10}", ErrorMessage = "Mobile must be 10 digits long")]
        public string MobileNo
        {
            get
            {
                return _mobileNo;
            }
            set
            {
                _mobileNo = value;
                this.OnPropertyChanged("MobileNo");
            }
        }
    }
}
